<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
    <title>知识点管理</title>
    <include file='Layout:ins_css'/>
    <style type="text/css">


    </style>
</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>知识点管理</h5>
                    <button class="btn btn-primary" id="addBtn">新增</button>
                </div>
                <div class="row s-row">
                    <div class="col-sm-12">
                        <div class="price-div">
                            <form class="form-horizontal">
                                <div class="form-group cyf-form-group">
                                    <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                        <label style="float: left" class="col-sm-4 control-label cvbnm">学院: </label>
                                        <select class="form-control col-sm-6" id="college_id" name="college_id"
                                                style="min-height: 35px">
                                            <option value="0">全部</option>
                                            <volist name="college_info" id="college_info">
                                                <option value="{$college_info.sch_id}">{$college_info.sch_name}</option>
                                            </volist>
                                        </select>
                                    </div>
                                    <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                        <label style="float: left; margin-right: 13px" class="col-sm-4 control-label cvbnm">系: </label>
                                        <select class="form-control col-sm-" id="department_id" name="department_id" style="min-height: 35px">
                                            <option value="0">全部</option>
                                            <volist name="department_info" id="department_info">
                                                <option value="{$department_info.dept_id}"
                                                        pid="{$department_info.sch_id}" class="select"
                                                        style="display: none;">{$department_info.dept_name}
                                                </option>
                                            </volist>
                                        </select>
                                    </div>
                                    <div class="col-sm-4" style="margin-top: 10px; margin-bottom: 10px">
                                        <label style="float: left;" class="col-sm-4 control-label cvbnm">课程: </label>
                                        <select class="form-control col-sm-" id="course_id" name="course_id" style="min-height: 35px">
                                            <option value="0">全部</option>
                                            <volist name="course_info" id="vo">
                                                <option value="{$vo.id}" pid="{$vo.par_id}" class="select"
                                                        style="display: none;">{$vo.name}
                                                </option>
                                            </volist>
                                        </select>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="ibox-content">
                    <table class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th width="25%">知识点编号</th>
                            <th width="25%">知识点名称</th>
                            <th width="25%">所属课程</th>
                            <th width="25%">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Modal 编辑专业-->
<div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="form_add">
                    <div class="form-group">
                        <label class="col-sm-3 control-label cvbnm nationality cyf-label">所属学院</label>
                        <select class="form-control poiu" id="sch_select" name="sch_select">
                            <option value="0">请选择</option>
                            <volist name="par_college" id="vo">
                                <option value="{$vo.sch_id}">{$vo.sch_name}</option>
                            </volist>
                        </select>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label cvbnm nationality cyf-label">所属系部</label>
                        <select class="form-control poiu" id="dept_select" name="dept_select">
                            <option value="0">请选择</option>
                            <volist name="par_department" id="par_department">
                                <option value="{$par_department.dept_id}" pid="{$par_department.sch_id}"
                                        class="p_department_id" style="display: none;">{$par_department.dept_name}
                                </option>
                            </volist>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label cvbnm nationality cyf-label">所属课程</label>
                        <select class="form-control poiu" id="cou_select" name="cou_select">
                            <option value="0">请选择</option>
                            <volist name="par_course" id="vo">
                                <option value="{$vo.id}" pid="{$vo.par_id}"
                                        class="p_department_id" style="display: none;">{$vo.name}
                                </option>
                            </volist>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label cvbnm nationality cyf-label">知识点编号</label>
                        <input type="text" id="course_id" name="course_id" class="form-control cyf-input removeData">
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label cvbnm nationality cyf-label">知识点名称</label>
                        <input type="text" id="input_name" name="course_name" class="form-control cyf-input removeData">

                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="add_btn">保存</button>
            </div>
        </div>
    </div>
</div>
<include file='Layout:ins_js'/>
<script type="text/javascript">
    $(document).ready(function () {
        //自检
        check_index();

        sTable = $(".table").DataTable({
            "fnServerParams": function (aoData) {
                aoData.push({
                    'name': 'course_id',
                    'value': $('select#course_id option:selected').val(),
                });
            },
            "bAutoWidth": false,
            "oLanguage": {
                "sLengthMenu": "每页 _MENU_ "
            },
            "sAjaxSource": "__URL__/knowlege_ShowDatatables", //调用php后台接口方法地址
            "aoColumns": [{
                'data': 'knowledge_id'
            }, {
                'data': 'knowledge_content'
            }, {
                'data': 'name'
            }, {
                "data": null,
                orderable: false,
                render: function (data, type, row, meta) {
                    return '<a type="button" class="btn btn-success" href="#" onclick=editFromID(this) >编辑</a>|<a type="button" class="btn btn-danger" href="#" onclick=delFromID(this) >删除</a>'
                }
            }]
        });
        <!--------    初始化select2     !-------->
        //学院
        $("#sch_select").select2({
            width: '280px',
            dropdownParent: $("#Modal")
        });
        //系部
        $("#dept_select").select2({
            width: '280px',
            dropdownParent: $("#Modal")
        });
        $('#cou_select').select2({
            width: '280px',
            dropdownParent: $("#Modal")
        });
    });
    //查询按钮
    $("select#college_id").change(function () {
        //console.log( $('select#college_id option:selected').val());
        var p_id = $("#college_id").val();
        $("#department_id option").hide();
        $('#department_id').val('0');
        $('option[pid=' + p_id + ']').show();
        sTable.ajax.reload();
    });
    $("select#department_id").change(function () {
        //console.log( $('select#college_id option:selected').val());
        var p_id = $('#department_id').val();
        $('#course_id option').hide();
        $('#course_id').val(0);
        $('option[pid=' + p_id + ']').show();
        sTable.ajax.reload();
    });
    $('select#course_id').change(function () {
        sTable.ajax.reload();
    });
    <!--------------   新增模态框相关     !----------------->
    //新增模态框弹出
    $("#addBtn").on('click', function() {
        $("#Modal").modal();
    });
    //新增模态框 - 学院 选择事件-
    $('select#sd_boss_add').change(function () {

    });

</script>
</body>
</html>